package chap15;

import java.util.ArrayList;
import java.util.Random;

public class RandomList<T> {
	private ArrayList<T> storage=new ArrayList<>();
	private Random random=new Random(47);
	public void add(T item){
		storage.add(item);
	}
	public T select(){
		return storage.get(random.nextInt(storage.size()));
	}
	public static void main(String[] args) {
		RandomList<String> s=new RandomList<>();
		for(String s1:"I am Ding Xin !".split(" ")){
			s.add(s1);
		}
		for(int i=0;i<10;i++){
			System.out.println(s.select());
		}
	}

}
